/**
 * 点线面模型库
 */
import request from '@/utils/request'
const modelBaseData = {
    // 标注
    marker: [
        // {
        //     img: 'http://mars3d.cn/project/es5/widgets/plot/img/label.jpg',
        //     icon: 'http://59.110.54.18:3000/bigemap.js/v2.1.0/images/marker-icon.png',
        //     name: '文字',
        //     type: 'billboard',
        //     drawingType: 'marker',
        //     text: true
        // },
    ],
    // 二维平面
    plane: [
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/polyline.jpg',
            name: '线',
            type: 'polyline',
            stick: false,
            // color: '#3388ff',
            // outlineColor: '#3388ff',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/polyline_clampToGround.jpg',
            name: '贴地线',
            type: 'polyline',
            stick: true,
            // color: '#ffff00',
            // outlineColor: '#ffff00',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/curve.jpg',
            name: '曲线',
            type: 'curve',
            stick: false,
            // color: '#3388ff',
            // outlineColor: '#3388ff',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/curve_clampToGround.jpg',
            name: '贴地曲线',
            type: 'curve',
            stick: true,
            // color: '#ffff00',
            // outlineColor: '#ffff00',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/polygon.jpg',
            name: '面',
            type: 'polygon',
            stick: false,
            // color: '#3388ff',
            // outlineColor: '#3388ff',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/polygon_clampToGround.jpg',
            name: '贴地面',
            type: 'polygon',
            stick: true,
            // color: '#ffff00',
            // outlineColor: '#ffff00',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/rectangle.jpg',
            name: '矩形',
            type: 'rectangle',
            stick: false,
            // color: '#3388ff',
            // outlineColor: '#3388ff',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/rectangle_clampToGround.jpg',
            name: '贴地矩形',
            type: 'rectangle',
            stick: true,
            // color: '#ffff00',
            // outlineColor: '#ffff00',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/circle.jpg',
            name: '圆',
            type: 'circle',
            stick: false,
            // color: '#3388ff',
            // outlineColor: '#3388ff',
            drawingType: 'plane'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/circle_clampToGround.jpg',
            name: '贴地圆',
            type: 'circle',
            stick: true,
            // color: '#ffff00',
            // outlineColor: '#ffff00',
            drawingType: 'plane'
        }
    ],
    // 三维立体
    stereoscopic: [
        // {
        //     img: 'http://mars3d.cn/project/es5/widgets/plot/img/extrudedCircle.jpg',
        //     name: '圆柱体',
        //      type: 'circle',
        //      color: '#00ff00',
        //      drawingType: 'stereoscopic'
        // },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/extrudedEellipse.jpg',
            name: '椭圆柱体',
            type: 'ellipse',
            // color: '#00ff00',
            drawingType: 'stereoscopic'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/plot/img/box.jpg',
            name: '长方体',
            type: 'box',
            // color: '#00ff00',
            drawingType: 'stereoscopic'
        }
    ],
    // 图上量算
    measure: [
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-length.svg',
            name: '空间距离',
            bgColor: '#dd751b'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-length2.svg',
            name: '贴地距离',
            bgColor: '#c092fe'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-section.svg',
            name: '剖面',
            bgColor: '#88b8ff'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-area.svg',
            name: '水平面积',
            bgColor: '#3de3f4'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-area.svg',
            name: '贴地面积',
            bgColor: '#c092fe'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-angle.svg',
            name: '方位角',
            bgColor: '#95d333'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-height.svg',
            name: '高度差',
            bgColor: '#55d5a0'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-height-sup.svg',
            name: '三角测量',
            bgColor: '#37bc41'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/measure/image/measure-coor.svg',
            name: '坐标测量',
            bgColor: '#babc31'
        }
    ],
    // 空间分析
    analysis: [
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/rzfx.svg',
            name: '日照分析',
            bgColor: '#dd751b'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/ksy.svg',
            name: '可视域',
            bgColor: '#c092fe'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/flfx.svg',
            name: '方量分析',
            bgColor: '#88b8ff'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/dxkw.svg',
            name: '地形开挖',
            bgColor: '#55d5a0'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/dbtm.svg',
            name: '地表透明',
            bgColor: '#b85555'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/pdpx.svg',
            name: '坡度坡向',
            bgColor: '#3de3f4'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/mxpq.svg',
            name: '模型剖切',
            bgColor: '#37bc41'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/mxyp.svg',
            name: '模型压平',
            bgColor: '#95d333'
        },
        {
            img: 'http://mars3d.cn/project/es5/widgets/analysis/img/mxcj.svg',
            name: '模型裁剪',
            bgColor: '#babc31'
        }
    ]
}
let modelBaseVm = ''
setTimeout(() => {
    getMarkerIconList()
}, 300)
export function getMarkerIconList() {
    if (sessionStorage.getItem('baseId')) {
        request
            .get('api/map/MapCodeController/getMapIcon', {
                baseId: sessionStorage.getItem('baseId'),
                specificationsType: ''
            })
            .then(res => {
                if (res.code == 200) {
                    // console.log(res)
                    modelBaseData.marker = []
                    res.data.forEach(v => {
                        if (v.specificationsType == 'PLANPOINT') {
                            let data = {
                                img: v.iconUrl,
                                icon: v.iconUrl,
                                name: v.specifications,
                                type: 'billboard',
                                drawingType: 'marker',
                                text: false
                            }
                            modelBaseData.marker.push(data)
                        }
                    })
                    setTimeout(() => {
                        if (modelBaseVm) {
                            modelBaseVm.getPageData()
                        }
                    }, 1000)
                }
            })
    }
}

export function modelBase(vue) {
    modelBaseVm = vue
    return new Promise((reslove, reject) => {
        reslove([
            {
                name: `点及文字(${modelBaseData.marker.length})`,
                data: modelBaseData.marker,
                type: 'marker'
            },
            {
                name: `二维平面(${modelBaseData.plane.length})`,
                data: modelBaseData.plane,
                type: 'plane'
            },
            {
                name: `三维立体(${modelBaseData.stereoscopic.length})`,
                data: modelBaseData.stereoscopic,
                type: 'stereoscopic'
            },
            {
                name: '图上量算',
                data: modelBaseData.measure,
                type: 'measure'
            },
            {
                name: '空间分析',
                data: modelBaseData.analysis,
                type: 'analysis'
            }
        ])
    })
}
